package com.dowsure.apisaas.api;

import com.dowsure.apisaas.enums.MethodEnums;
import com.dowsure.apisaas.exception.ApiException;
import com.dowsure.apisaas.model.WebhookRequestParams;
import com.dowsure.apisaas.util.ApiClient;
import com.dowsure.apisaas.util.ApiResponse;
import com.dowsure.apisaas.util.RequestParamValidatedUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: dowsure-apisaas-sdk
 * @description: webhook
 * @author: Dowsure
 * @create: 2022-02-16 16:41
 **/
public class WebhookApi {

    private ApiClient apiClient;

    public WebhookApi(ApiClient apiClient){
        this.apiClient = apiClient;
    }


    /**
     * 19、webhook设置（API-C14）
     * 设置webhook的配置项。
     * @author Dowsure
     * @param webhookRequestParams {@link WebhookRequestParams}
     * @return {@link ApiResponse <Void>}
     * @throws ApiException
     */
    public ApiResponse<Void> webhook(WebhookRequestParams webhookRequestParams) throws ApiException {
        RequestParamValidatedUtils.validated(webhookRequestParams);
        String localVarPath = "/v1/webhook";

        Map<String, String> headerParams = new HashMap<>();
        com.squareup.okhttp.Call call = apiClient.buildCall(localVarPath, MethodEnums.POST, webhookRequestParams, headerParams);
        return apiClient.execute(call);
    }
}
